<template>
    <!-- 积分页面 -->
    <view class="jf-container">
        <view class="top-bg">
            <view class="jfbgbox">
                <image src="../../static/assets/img/jifenBG.png"></image>
            </view>
            <view class="titleTop">
                <image src="../../static/assets/img/return@2x.png" class="titleimg" @tap="goBack"></image>
                <text>积分明细</text>
                <text></text>
            </view>
            <view class="jfTabox">
                <view class="jfTabox-list">
                    <view class="dqjf">当前积分</view>
                    <view class="jfnumber">{{ myJf.integraBalance || 0 }}</view>
                    <view class="dqjf">累计已兑换 {{ myJf.integraUsedMoney || 0 }}积分</view>
                </view>
                <view class="jfTabox-list">
                    <image class="jifen_card" src="../../static/assets/img/jifen_card.png" alt=""></image>
                </view>
            </view>
        </view>
        <view class="jfdh">
            <view style="background: #fff">
                <view class="jf-title">积分明细</view>
                <view class="jfdh-list">
                    <view class="list-box" style="margin-top: 24rpx" v-for="(item, index) in jfdetailList" :key="item.i">
                        <view class="title-box">
                            <view>
                                <image src="../../static/assets/img/jficon.png" style="width: 44rpx; height: 44rpx; margin-right: 14rpx; margin-left: 18rpx"></image>
                            </view>
                            <view>
                                <view class="jf-name">{{ item.remark }}</view>
                                <view class="jf-time">{{ item.indicatorDay }}</view>
                            </view>
                        </view>

                        <view>
                            <text class="jfdh-list-price">{{ item.integraNum || 0 }}积分</text>
                        </view>
                    </view>
                </view>
            </view>
        </view>
        <!-- <view class="coupon-img">
    <image src="/assets/img/coupon.png"></image>
  </view>
  <view class="coupon-text">暂无积分</view> -->
    </view>
</template>

<script>
import util from './../../utils/util.js';
import api from './../../utils/api.js';
export default {
    data() {
        return {
            jfdetailList: [],

            myJf: {
                integraBalance: '',
                integraUsedMoney: ''
            }
        };
    },
    onLoad: function (options) {},
    onReady: function () {},
    onShow: function () {
        if (uni.getStorageSync('AUTHORIZATION')) {
            const unionId = uni.getStorageSync('unionId');
            this.getMyIntegra(unionId);
            this.findIntegraList(unionId);
        }
    },
    methods: {
        goBack() {
            //返回上一级
            uni.navigateBack({
                delta: 1
            });
        },

        getMyIntegra(unionId) {
            //我的积分
            util.request(api.getMyIntegra + '?unionId=' + unionId, 'get').then((res) => {
                if (res.code == 0) {
                    this.setData({
                        myJf: res.data
                    });
                } else {
                    uni.showToast({
                        title: res.msg,
                        icon: 'none'
                    });
                }
            });
        },

        findIntegraList(unionId) {
            //积分明细
            const parm = {
                unionId,
                pageSize: 100,
                pageNumber: 1
            };
            util.request(api.findIntegraList, parm, 'POST').then((res) => {
                if (res.code == 0) {
                    this.setData({
                        jfdetailList: res.data.content
                    });
                } else {
                    uni.showToast({
                        title: res.msg,
                        icon: 'none'
                    });
                }
            });
        }
    }
};
</script>
<style>
@import './jfdetails.css';
</style>
